#!/bin/bash

DEPLOY_DIR="ppui-book"

CWD=$(cd $(dirname $0); pwd -P)

echo "packing:"
PKG_NAME=deploy.tar.gz

mkdir -p output/
rm -rf output/*
mkdir -p output/$DEPLOY_DIR

which gitbook > /dev/null

if [ $? == 0 ]
then
    gitbook build
    cp -fr _book/* output/$DEPLOY_DIR
else
    echo "gitbook not found"
fi

cd output/
tar -cvzf $PKG_NAME $DEPLOY_DIR
mv $PKG_NAME ../
cd $CWD
rm -rf output/*
mv $PKG_NAME output/

echo "done"
